package io.renren.modules.api.controller;

import io.renren.common.utils.ConstantUtils;
import io.renren.common.utils.R;
import io.renren.common.utils.UploadUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @program: stf
 * @description: 上传
 * @author: Custom
 * @create: 2018-11-04 18:47
 **/
@RestController
@RequestMapping("/api")
public class ApiUploadController {


    //图片上传
    @PostMapping("/upload/img")
    public R upload(MultipartFile img, HttpSession session, @RequestParam int type) throws IOException {
        if(type == UploadUtils.SLIDESHOW){
            return R.error("图标类型标识错误");
        }
        R uploadImage = UploadUtils.uploadImage(new MultipartFile[]{img}, ConstantUtils.imageUrlPath, type);
        return uploadImage;
    }

}
